<?php
    /**
    * Auth.php
    * 
    * @author Osuvaldo Ramos <xdracox@gmail.com>
    * @copyright Copyright (c) 2008, Osuvaldo Ramos
    * @license http://www.opensource.org/licenses/bsd-license.php
    * @package Atman
    */
    
    /**
    * Base class for authorization methods.
    * @package Atman
    */
    abstract class AT_Auth extends AT_Object
    {
        /**
        * __construct()
        */
        public function __construct()
        {
            parent::__construct();
        }
        
        /**
        * Checks if the current user has enough authorization for the module.
        * @return boolean
        */
        public abstract function authenticate();
        
        /**
        * A factory method that returns an authentication method of the
        * type requested.
        * @param string $type The authorization method.
        */
        public static function factory($type)
        {
            $className = 'AT_Auth_'.$type;
            $ret = new $className;
            
            if ( $ret instanceof AT_Auth )
            {
                return $ret;
            }
            else
            {
                $msg = 'Invalid authorization type.';
                $this->reportError($msg, PEAR_LOG_ALERT);
            }
        }
        
        /**
        * __destruct()
        */
        public function __destruct()
        {
            parent::__destruct();
        }
    }
?>
